package com.example.xposeddemo;

import android.util.Log;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XSharedPreferences;
import de.robv.android.xposed.XposedHelpers;

public class SystemPropertiesHook extends XC_MethodHook
{
    public SystemPropertiesHook()
    {
        super();
    }

    protected void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable
    {
        XSharedPreferences pre = new XSharedPreferences(this.getClass().getPackage().getName(), "deviceInfo");
        String methodName = param.method.getName();
        if (methodName.startsWith("get"))
        {
            Log.v("getDeviceInfo", "hook systemProperties ------>");
            XposedHelpers.setStaticObjectField(android.os.Build.class, "MODEL", pre.getString("model", null));
            XposedHelpers.setStaticObjectField(android.os.Build.class, "MANUFACTURER", pre.getString("manufacturer", null));
            XposedHelpers.setStaticObjectField(android.os.Build.class, "BRAND", pre.getString("brand", null));
            XposedHelpers.setStaticObjectField(android.os.Build.class, "HARDWARE", pre.getString("hardware", null));
            XposedHelpers.setStaticObjectField(android.os.Build.class, "RADIO", pre.getString("radio", null));
            XposedHelpers.setStaticObjectField(android.os.Build.class, "DEVICE", pre.getString("device", null));
        }
    }
}
